home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2052 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  29 lines

  1. Newsgroups: comp.lang.c
  2. Path: thinkage.on.ca!atbowler
  3. From: atbowler@thinkage.on.ca (Alan Bowler)
  4. Subject: Re: GoTo equivalent in C ??
  5. Message-ID: <DLE24I.Jur@thinkage.on.ca>
  6. Sender: news@thinkage.on.ca
  7. Organization: Thinkage Ltd.
  8. References: <4d67vm$e5h@masala.cc.uh.edu> <4d8sa6$mqc@news.iag.net> <4de4ae$h6a@masala.cc.uh.edu>
  9. Date: Thu, 18 Jan 1996 18:02:41 GMT
  10.  
  11. In article <4de4ae$h6a@masala.cc.uh.edu> sukku@menudo.uh.edu (sukumar) writes:
  12. >
  13. >What does everyone do?? I have always been tempted to use goto especially in 
  14. >functions involving a lot of computation and error checking.
  15. >I have heard people say "People who don't know how to code use GOTO". I was
  16. >curious to know how guys that say this solve the above problem.
  17. >
  18. The people who make such blanket statements about goto's are just
  19. wrong.  Used judiciously, goto's are a valuable part of a programmer's
  20. tool kit.  It is true that any goto/label pair can be replaced with
  21. some set of if/while/flag-variables but applying this approach
  22. mechanically results in even worse spaghetti.  Back when I was first
  23. getting into the buisiness (Before the famous "Goto's considered
  24. harmful" letter), a shop I worked at had a style prohibition against
  25. switch variables.  
  26.  
  27. One common case where goto's are often the best choice is the
  28. "ooops, something failed, goto common cleanup code" situation.
  29.